var system={};
system.User={};
system.User.initGrid = function(){
	var options = {};
    var colNames = ["","序号","用户名","真实名称","编号","状态","角色","添加时间"];
    var colModel = [
        {name:"myac",fixed:true,width:55,align:"center",formatter:customActions,formatoptions:{
        	keys:true,
        	editUrl:"preEdit.jspx?id=",
        	canDel:false
        	}},
        {name:"id",index:"id",fixed:true,width:45,align:"center",key:true},
        {name:"username",index:"username",width:35,editable:true},
        {name:"realname",index:"realname",width:25,editable:true},
        {name:"code",index:"code",width:15},
        {name:"status",index:"status",width:20,align:'center'},
        {name:"roleNames",index:"roleIds",width:35},
        {name:"addtime",index:"addtime",width:25}
    ];
    options = {colNames:colNames,
               colModel:colModel,
               newUrl:"preAdd.jspx",
               editUrl:"preEdit.jspx?id=",
               canDel:false,
               caption:"用户列表"};
    
    customGrid.init(options);
};
system.User.roles = function(options){
	$.get(options.url,function(data){
		if(data!==undefined){
			var roleIds = data.roleIds;
			$("input[name='roleIds']").attr("checked",false);
			$.each(roleIds,function(index,roleid){
				$("input[name='roleIds'][value='"+roleid+"']").attr("checked",true);
			});
		}
	});
};
system.User.Edit={};
system.User.Edit.init=function(options){
	$(":input[name='status'][value='"+options.status+"']").attr("checked",true);
};
system.Login = {};
system.Login.validator = function(){
	var $validator = $("#form-data").validate({
		rules:{
			username:"required",
			password:"required"
		},
		messages:{
			username:"请输入用户名",
			password:"请输入密码"
		}
	});
	$("#reset").on("click",function(){
		$validator.resetForm();
	});
};

system.UserStation={};
system.UserStation.initGrid = function(){
	var options = {};
    var colNames = ["","序号","用户名","工位"];
    var colModel = [
        {name:"myac",fixed:true,width:80,formatter:customActions,formatoptions:{
        	keys:true,
        	editUrl:"preEdit.jspx?id="
        	}},
        {name:"id",index:"id",fixed:true,width:55,key:true},
        {name:"userName",index:"userName",width:35},
        {name:"stationName",index:"stationName",width:25}
    ];
    options = {colNames:colNames,
               colModel:colModel,
               newUrl:"preAdd.jspx",
               editUrl:"preEdit.jspx?id=",
               canDel:"delete.jspx",
               caption:"用户工位列表"};
    
    customGrid.init(options);
};